<?php
// Do not delete these lines
	if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('welcome here,bengshuo.com');

	if ( post_password_required() ) { ?>
		<p class="nocomments">need password</p> 
	<?php
		return;
	}
?>

<?php if ( have_comments() ) : ?>
	<h3 id="comments">评论也精彩</h3>

	<ol class="commentlist">
		<?php wp_list_comments();?>
	</ol>

	<div class="navigation">
		<div class="alignleft"><?php previous_comments_link() ?></div>
		<div class="alignright"><?php next_comments_link() ?></div>
	</div>

 <?php else : //没有评论?>
	<?php if ( comments_open() ) : ?>
	<?php else :?>
	<p class="nocomments">抱歉,评论睡觉时间.</p>
	<?php endif; ?>
<?php endif; ?>

<?php if ( comments_open() ) : ?>
<script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.validate.js"></script>
<div id="respond">
	<h3>留下你的评论</h3>
	<div id="cancel-comment-reply"> 
		<small><?php cancel_comment_reply_link('取消') ?></small>
	</div> 
<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
	<p><?php printf('<a href="%s">Login</a> to post a comment', wp_login_url( get_permalink() )); ?></p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( is_user_logged_in() ) : ?>
	<p><?php printf('<a href="%1$s">%2$s</a>', get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Logout">Logout&raquo;</a>
	</p>
<?php else : ?>

<p>
<label for="author">姓名</label>
<input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
</p>

<p>
<label for="email">邮箱</label>
<input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
</p>

<p>
<label for="url">博客</label>
<input type="text" name="url" id="url" value="<?php echo  esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
</p>

<?php endif; ?>

<p>
<label for="comment">填写内容</label>
<textarea name="comment" id="comment" cols="58" rows="5" tabindex="4"></textarea></p>
<p>

<?php do_action('comment_form', $post->ID); ?>
<input name="walleve_submit" type="submit" id="walleve_submit" tabindex="5" value="提交" />
<?php comment_id_fields(); ?> 
</p>

</form>
<script type="text/javascript">
$.validator.setDefaults({
	submitHandler: function(form) {
		form.submit();
	}
});
$(document).ready(function() {
	$("#commentform").validate({
		rules: {
			author: {
				required: true,
			},
			email: {
				required: true,
				email: true
			},
			comment:{
				required:true,
				minlength:6
			}
		},
		messages: {
			author: {
				required: "输入你的常用昵称",
			},
			email: {
				required: "输入正确的邮箱地址",
				email:"输入正确的邮箱地址"
			},
			comment:{
				required: "评论不够深刻",
				minlength:"评论不够深刻（至少6个字）"
			}
		}
	});
});
</script>
<?php endif; ?>
</div>

<?php endif; ?>